import sys
import time

import pyautogui
import  myMethods
path = sys.path[0]
def login():
    global  pos
    if pos != None:

        pos = pyautogui.locateCenterOnScreen(path + r"img\account1.png")
        if pos == None:
            myMethods.click("login1")
        else:
            pyautogui.click(pos)
            time.sleep(0.5)
            pyautogui.press("shift")
            pyautogui.write("392221")
            pyautogui.press("enter")
            pyautogui.press("enter")
            myMethods.click("passwd")
            pyautogui.write("03215735")

            myMethods.click("save", flag=-35)
            myMethods.click("login1")


    else:
        pos = pyautogui.locateCenterOnScreen(path + r"img/account2.png", confidence=0.9)
        if pos == None:
            myMethods.click("login2")
        else:
            pyautogui.click(pos)
            time.sleep(0.5)
            pyautogui.press("shift")
            pyautogui.write("392221")
            myMethods.click("passwd2")
            pyautogui.write("03215735")
            myMethods.click("save", flag=-35)
            myMethods.click("login2", sim=0.9)


myMethods.click("unfold")
time.sleep(0.5)
pos = pyautogui.locateCenterOnScreen(path + r"img\net.png",confidence=0.7)
if pos !=None:
    myMethods.click("net")
    myMethods.find("szunet")
    myMethods.click("szunet")
    myMethods.click("connect")
    time.sleep(5)
# 双击登录校园网
pos3 =pyautogui.locateCenterOnScreen(path + r"img\loginwindow.png")
if pos3 ==None:
    myMethods.click("loginNet")
    myMethods.click("loginNet")
    time.sleep(3)

pos2 =pyautogui.locateCenterOnScreen(path + r"img\zhuxiao.png",confidence=0.8)
if pos2== None:
    login()

myMethods.click("minimize")

myMethods.click("minimize")
args = sys.argv
print(args)